Moving characters on a grid [on hold]

Posted by madmax1 on Game Development See other posts from Game Development or by madmax1
Published on 2014-06-09T13:19:47Z Indexed on 2014/06/09 15:43 UTC
Read the original article Hit count: 264

Filed under:
|
|
|

i am developing my first game with C++. My game uses a grid of rectangles. I have a class Board which manages the grid as a whole, initializes the terrain, places/removes characters, etc. It has a 2D vector of a class Field, which handles the Structure of the field, contained Objects, Characters, etc. Field again contains a vector of class Character, which are positioned on the field.

Now i want to implement the functionality to move a character on the board, however dont know which is best practice to do so. Should i implement a moveCharacter(character, offset) function in Board, make it search for the character and move it? Or should i implement a function move(offset) in Character? This sure would be nicest, however makes characters necessary to know the board they are on, or the field which in turn knows the board. On the one hand i feel like i should avoid inclusion between classes as much as possible e.g. to increase portability of classes for different projects, on the other hand i think the character.move() functionality is most comfortable for further development.

Im pretty new to "bigger" C++ projects and these kind of design questions pop up more and more often lately and i have troubles deciding.

Thanks a lot for any advice!

© Game Development or respective owner

Related posts about c++

Related posts about 2d